package com.atguigu.lease.web.app.custom.config;

import com.atguigu.lease.web.app.interceptor.AuthenticationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName AppMvcConfig
 * @Author heartFade
 * @Date 2025-05-06 9:42
 * @Version 1.0
 * @Description TODO
 **/
@Configuration
@PropertySource("classpath:application.yaml")
public class AppMvcConfig implements WebMvcConfigurer {
    @Autowired
    private AuthenticationInterceptor authenticationInterceptor;

     @Value("${app.auth.path-patterns.include}")
     private String includePath;

     @Value("${app.auth.path-patterns.exclude}")
     private String excludePath;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationInterceptor).addPathPatterns(includePath)
                .excludePathPatterns(excludePath);
    }
}
